<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<% String path = request.getContextPath();%>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 数据表格</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="<%=path%>/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="<%=path%>/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <link href="<%=path%>/admin/css/animate.css" rel="stylesheet">
    <link href="<%=path%>/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-md-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h3>
                        可根据以下条件搜索过滤<small>本商城内所有的商品数据,可按照以下指示进行操作以及Excel数据导入导出</small>
                    </h3>
                    <div class="clearfix"></div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-md-2 form-group">
                            <input value="${goodsId}" type="text" placeholder="商品编号" class="form-control"
                                   name="goodsId">
                        </div>
                        <div class="col-md-2 form-group">
                            <input value="${goodsName}" type="text" placeholder="商品名字" class="form-control"
                                   name="goodsName">
                        </div>
                        <div class="col-md-2 form-group">
                            <select class="form-control m-b" name="account" id="typeId">
                                <option value="0" id="goodsType">-商品类型-</option>
                                <c:forEach items="${goodsTypeList}" var="type">
                                    <option value="${type.typeId}">${type.typeName}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <div class="col-md-6 form-group">
                            <label class="radio-inline">
                                <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">已上架
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">未上架
                            </label>
                            <button id="search" type="submit" class="btn btn-success">搜索</button>
                            <a class="btn btn-sm btn-primary" data-toggle="modal" data-target="#updateModel"><i class="fa fa-plus" ></i>新增商品</a>
                            <%--<button type="button" class="btn btn-info"><i class="fa fa-cloud-upload"></i>批量导入商品信息</button>
                            <button type="button" class="btn btn-primary"><i class="fa fa-cloud-download"></i>导出商品数据到Excel表格</button>--%>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th>商品编号</th>
                            <th>商品名称</th>
                            <th>SEO关键字</th>
                            <th>市场价格</th>
                            <th>店铺价格</th>
                            <th>商品总库存</th>
                            <th>预警数量</th>
                            <th>销售量</th>
                            <th>商品图片</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${goodsList}" var="goods">
                            <tr class="gradeX">
                                <td>${goods.goodsSn} </td>
                                <td>${fn:substring(goods.goodsName,0,5).concat('...')}</td>
                                <td>${goods.goodsKeywords}</td>
                                <td>${goods.marketPrice} </td>
                                <td>${goods.shopPrice}</td>
                                <td>${goods.goodsStock}</td>
                                <td>${goods.warnStock}</td>
                                <td>${goods.saleCount}</td>
                                <td class="center">
                                    <img src="${goods.goodsImg}" width="30" height="30" id="images"
                                         <%--onmouseover="return amplification(${goods.goodsImg})"--%>>
                                </td>
                                <td class="center">
                                    <a class="btn btn-sm btn-danger" href="commodity?type=soldOut&goodId=${goods.goodsId}"><i class="fa fa-arrow-circle-down"></i>下架</a>
                                    <a class="btn btn-sm btn-primary" data-toggle="modal" data-target="#updateModel" onclick="edit(${goods.goodsId})"><i class="fa fa-edit"></i>修改商品数据</a>
                                    <a class="btn btn-sm btn-success" data-toggle="modal" data-target="#updateModel"><i class="fa fa-eye"></i>查看商品详情</a>
                                    <a class="btn btn-sm btn-warning" data-toggle="modal" data-target="#updateModel"><i class="fa fa-history"></i>该商品销售记录</a>

                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>
</div>
</div>
</div>
<!-- 弹框代码新增-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabels">颜色选择</h4>
            </div>
            <div class="modal-body">
                <div class="input-group colorpicker-component demo demo-auto colorpicker-element">
                    <div >
                        <form action="/orange/goods?type=add" method="post" role="form" class="form-horizontal m-t" id="commentForms" novalidate="novalidate">

                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品编号：</label>
                                <div class="col-sm-8">
                                    <input id="goodsSns" name="goodsSn" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品名称：</label>
                                <div class="col-sm-8">
                                    <input id="goodsNames" name="goodsName" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品图片：</label>
                                <div class="col-sm-8">
                                    <input id="goodsImgs" type="text" class="form-control" name="goodsImg" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">店铺价格：</label>
                                <div class="col-sm-8">
                                    <input id="shopPrices" type="text" class="form-control" name="shopPrice" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品总库存：</label>
                                <div class="col-sm-8">
                                    <input id="goodsStocks" type="text" class="form-control" name="goodsStock" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">市场价格：</label>
                                <div class="col-sm-8">
                                    <input id="marketPrices" type="text" class="form-control" name="marketPrice" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">销售数量：</label>
                                <div class="col-sm-8">
                                    <input id="saleCounts" type="text" class="form-control" name="saleCount" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品类型：</label>
                                <div class="col-sm-8">
                                    <input id="goodsTypeIds" type="text" class="form-control" name="goodsTypeId" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button  class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

<!-- 弹框代码 修改-->
<div class="modal fade" id="updateModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">修改</h4>
            </div>
            <div class="modal-body">
                <div class="input-group colorpicker-component demo demo-auto colorpicker-element">
                    <div >

                        <form action="commodity?type=updateGoods" method="post" role="form" class="form-horizontal m-t" id="commentForm" novalidate="novalidate">
                            <input id="goodsId" name="goodsId" type="text"  hidden="hidden">

                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品编号：</label>
                                <div class="col-sm-8">
                                    <input id="goodsSn" name="goodsSn" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品名称：</label>
                                <div class="col-sm-8">
                                    <input id="goodsName" name="goodsName" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品图片：</label>
                                <div class="col-sm-8">
                                    <input id="goodsImg" type="text" class="form-control" name="goodsImg" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">店铺价格：</label>
                                <div class="col-sm-8">
                                    <input id="shopPrice" type="text" class="form-control" name="shopPrice" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品总库存：</label>
                                <div class="col-sm-8">
                                    <input id="goodsStock" type="text" class="form-control" name="goodsStock" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">市场价格：</label>
                                <div class="col-sm-8">
                                    <input id="marketPrice" type="text" class="form-control" name="marketPrice" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">销售数量：</label>
                                <div class="col-sm-8">
                                    <input id="saleCount" type="text" class="form-control" name="saleCount" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">商品类型：</label>
                                <div class="col-sm-8">
                                    <input id="goodsTypeId" type="text" class="form-control" name="goodsTypeId" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button  class="btn btn-primary" type="submit" onclick="submit(${goods.goodsId})">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script src="<%=path%>/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/admin/js/bootstrap.min.js?v=3.3.6"></script>



<script src="<%=path%>/admin/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="<%=path%>/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="<%=path%>/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<script src="<%=path%>/admin/js/content.js?v=1.0.0"></script>

<script type="text/javascript">
    $(function () {
        $(".ibox-content table").dataTable({
            paging: true,//分页
            ordering: true,//是否启用排序
            searching: false,//搜索
            lengthChange:false,//每页显示大小调整
            pageLength:5, //显示条数
            language: {
                paginate: {//分页的样式内容。
                    previous: "上一页",
                    next: "下一页",
                    first: "第一页",
                    last: "最后"
                },

                zeroRecords: "没有内容",//table tbody内容为空时，tbody的内容。
                //下面三者构成了总体的左下角的内容。
                info: "总共_PAGES_ 页，显示第_START_ 到第 _END_ ，筛选之后得到 _TOTAL_ 条，初始_MAX_ 条 ",//左下角的信息显示，大写的词为关键字。
                infoEmpty: "0条记录",//筛选为空时左下角的显示。
                infoFiltered: ""//筛选之后的左下角筛选提示，
            },
            paging: true,
            pagingType: "full_numbers",//分页样式的类型

        });
    });
    //修改查询
    function  edit(id) {
        $.ajax({
            url:"commodity?type=goodsById&goodsId="+id,
            type:"get",
            dataType:"json",
            success:function (data) {
                $("#goodsId").val(id);
                $("#goodsSn").val(data.goodsSn);
                $("#goodsName").val(data.goodsName);
                $("#goodsImg").val(data.goodsImg);
                $("#shopPrice").val(data.shopPrice);
                $("#goodsStock").val(data.goodsStock);
                $("#marketPrice").val(data.marketPrice);
                $("#saleCount").val(data.saleCount);
                $("#goodsTypeId").val(data.goodsTypeId);
            }
        })
    }

</script>
<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {
        $('.dataTables-example').dataTable();

        /* Init DataTables */
        var oTable = $('#editable').dataTable();

        /* Apply the jEditable handlers to the table */
        oTable.$('td').editable('../example_ajax.php', {
            "callback": function (sValue, y) {
                var aPos = oTable.fnGetPosition(this);
                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition(this)[2]
                };
            },

            "width": "90%",
            "height": "100%"
        });


    });

    function fnClickAddRow() {
        $('#editable').dataTable().fnAddData([
            "Custom row",
            "New row",
            "New row",
            "New row",
            "New row"]);

    }
</script>

<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<!--统计代码，可删除-->
<script>
    $(function () {
        location.href="goodsInfo?type=goodsType";
    });
    $("#search").click(function () {
        location.href="commodity?type=search&goodsId="+$("[name='goodsId']").val()+"&goodsName="+$("[name='goodsName']").val()+"&goodsType="+$("#typeId").val();
    });


    //放大商品图片
    /*function amplification(img){
        document.getElementById("images").src=img;
        document.getElementById("images").style.width="400px";
    }*/
</script>

</body>

</html>
